import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

// 引入登路组件
import Login from  "../views/login/index.vue"

import Layout from  "../views/layout/index.vue"
const routes = [
  // 定义路由
  {path:"/",redirect:"/login"},
  {path:"/login",component:Login},

  {path:"/",meta:{title:"首页"},component:Layout,redirect:"/home",children:[
  {path:"home",meta:{title:"首页"},component:()=>import("../views/home/index.vue")}
  ]},
  // 用户列表
  {path:"/users",meta:{title:"用户管理"},component:Layout,redirect:"/users/users",children:[
    {path:"users",meta:{title:"用户列表"},component:()=>import("../views/users/index.vue")},
  ]},
  // 权限管理
  {path:"/rights",meta:{title:"权限管理"},component:Layout,redirect:"/diction/rights",children:[
    {path:"roles",meta:{title:"角色列表"},component:()=>import("../views/rights/role.vue")},
    {path:"rights",meta:{title:"权限列表"},component:()=>import("../views/rights/list.vue")},
  ]},
  // 商品管理
  {path:"/goods",meta:{title:"商品管理"},component:Layout,redirect:"/diction/goods/",children:[
    {path:"goods",meta:{title:"商品列表"},component:()=>import("../views/goods/goodsList.vue")},
    {path:"params",meta:{title:"商品参数"},component:()=>import("../views/goods/goodsParams.vue")},
    {path:"categories",meta:{title:"商品分类"},component:()=>import("../views/goods/goodsCategories.vue")},
    {path:"comgoodsaddto",meta:{title:"商品添加"},component:()=>import("../components/ComGoodsaddto.vue")},
  ]},
  // 订单管理
  {path:"/orders",meta:{title:"订单管理"},component:Layout,redirect:"/orders/orders", children:[
    {path:"orders",meta:{title:"订单列表"},component:()=>import("../views/orders/index.vue")}
  ]},
  // 数据统计
  {path:"/reports",meta:{title:"数据统计"},component:Layout,redirect:"/reports/reports", children:[
    {path:"reports",meta:{title:"数据报表"},component:()=>import("../views/reports/index.vue")}
  ]}
]

const router = new VueRouter({
  mode:"history",
  routes
})

export default router
